struct Solution {}

// impl Solution {
//   pub fn find_ocurrences(text: String, first: String, second: String) -> Vec<String> {
//     let words: Vec<_> = text.split(' ').collect();
//     let mut l: usize = 0;
//     let mut ret = vec![];
//     while l < words.len() - 2 {
//       if words[l] == first && words[l + 1] == second {
//         ret.push(words[l + 2].to_string());
//       } 
//       l += 1;
//     }
//     ret
//   }
// }

impl Solution {
  pub fn find_ocurrences(text: String, first: String, second: String) -> Vec<String> {
    text.split_whitespace().collect::<Vec<_>>().windows(3).filter(|w| w[0] == &first && w[1] == &second).map(|w| w[2].to_string()).collect()
  }
}